<template>
  <el-dialog
    :title="'购房情况查询'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="140px">

    <el-form-item label="委托书编号" prop="proxyno">
      <el-input v-model="dataForm.proxyno" placeholder="委托书编号" disabled></el-input>
    </el-form-item>

    <el-form-item label="被查询人名称" prop="name">
      <el-input v-model="dataForm.name" placeholder="被查询人名称" disabled></el-input>
    </el-form-item>
    <el-form-item label="被查询人证件号码" prop="idcode">
      <el-input v-model="dataForm.idcode" placeholder="被查询人证件号码" disabled></el-input>
    </el-form-item>

    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {

      return {
        visible: false,
        dataForm: {
          proxyno: '',
          region: '',
          name: '',
          idcode: ''
        },
        dataRule: {


        }
      }
    },
    methods: {
      init (region, proxyno, name, idcode) {
        this.visible = true

        this.dataForm.region = region
        this.dataForm.proxyno = proxyno
        this.dataForm.name = name
        this.dataForm.idcode = idcode

        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()

        })
      },

      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcpurchase/sendByProxyno`),
              method: 'post',

              data: this.$http.adornData({
                'region': this.dataForm.region,
                'proxyno': this.dataForm.proxyno,
                'name': this.dataForm.name,
                'idcode': this.dataForm.idcode
              })

            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '查询成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$router.push({ name: 'bdc-bdcpurchase' })
                    // this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
<style>
.el-input.is-disabled .el-input__inner {
    background-color: #f5f7fa;
    border-color: #e4e7ed;
    color: #313b50;
    cursor: not-allowed;
}
</style>